local skill = fk.CreateSkill {
  name = "ls_jixi__secret_advance_skill",
}

Fk:loadTranslationTable{
  ["ls_jixi__secret_advance_skill"] = "暗度陈仓",
  ["#jixi_secret_advance-give"] = "你可额外交给 %dest 一张牌，令此阶段改为出牌阶段",
}

skill:addEffect("cardskill", {
  prompt = "#lvshi__secret_advance_skill",
  target_num = 1,
  mod_target_filter = function(self, player, to_select, selected, card)
    return to_select ~= player and not to_select:isAllNude()
  end,
  target_filter = Util.CardTargetFilter,
  on_effect = function(self, room, effect)
    local player = effect.from
    local target = effect.to
    local cards = room:askToChooseCards(player, {
      target = target,
      min = 1,
      max = 2,
      flag = "hej",
      skill_name = skill.name,
    })
    room:obtainCard(player, cards, false, fk.ReasonPrey, player, skill.name)
    if not player.dead and not target.dead or player:isKongcheng() then
      local n = math.min(#cards, player:getHandcardNum())
      if player:getMark("ls__jixi-turn") > 0 then
        room:addPlayerMark(player, "jixi_buff-phase")
      else
        if n < player:getHandcardNum() and room:askToSkillInvoke(player,
        {skill_name = skill.name, prompt = "#jixi_secret_advance-give::"..target.id}) then
          n = n + 1
          room:addPlayerMark(player, "jixi_buff-phase")
        end
      end
      cards = room:askToCards(player, {
        min_num = n,
        max_num = n,
        include_equip = false,
        skill_name = skill.name,
        prompt = "#secret_advance-give::"..target.id..":"..n,
        cancelable = false,
      })
      room:obtainCard(target, cards, false, fk.ReasonGive, player, skill.name)
    end
  end,
})

return skill
